package com.skycode7.servlet;
import com.skycode7.dao.NoticeDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/NoticeDel.jsp")
public class NoticeDelServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String NoticeId= req.getParameter("NoticeId");
        int result = (new NoticeDao().delete(Integer.parseInt(NoticeId)));
        if (result > 0) {
            resp.sendRedirect("news.html");
        }else{
            req.getRequestDispatcher("WEB-INF/error.jsp").forward(req, resp);
        }
    }
}
